package ventanas;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import controladores.ControladorVentanaPrincipal;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import java.awt.Color;
import javax.swing.ImageIcon;

import negocio.Sistema;

import java.awt.Font;

public class VentanaPrincipal extends JFrame {
	
	private static final long serialVersionUID = 1L;
	private JPanel contentPane;
	private final JButton btnMedicos = new JButton("M\u00E9dicos");
	private final JButton btnPacientes = new JButton("Pacientes");
	private final JButton btnVerAgenda = new JButton("Agendas de M\u00E9dicos");
	private final JButton btnEspecialidades = new JButton("Especialidades");
	private final JButton btnObrasSociales = new JButton("Obras Sociales");
	private final JLabel lblNewLabel = new JLabel("");
	private ControladorVentanaPrincipal controlador;
	private final JButton btnSalir = new JButton("Salir");
	
	public VentanaPrincipal() {
		setTitle("Medic-Soft");
		Sistema.obtenerInstancia();
		controlador = new ControladorVentanaPrincipal(this);
		initGUI();
		agregarListeners();
	}
	
	private void initGUI() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 563, 291);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setVisible(true);
		contentPane.setLayout(new FormLayout(new ColumnSpec[] {
				FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
				ColumnSpec.decode("121px"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("134px"),
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(95dlu;default)"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("max(51dlu;default)"),},
			new RowSpec[] {
				FormFactory.LINE_GAP_ROWSPEC,
				RowSpec.decode("14px"),
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("27px"),
				RowSpec.decode("23px"),
				RowSpec.decode("46px"),
				RowSpec.decode("23px"),
				RowSpec.decode("18px"),
				RowSpec.decode("23px"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("max(31dlu;default)"),}));
		contentPane.add(btnVerAgenda, "2, 5, 3, 1, fill, top");
		lblNewLabel.setIcon(new ImageIcon(VentanaPrincipal.class.getResource("/images/MedicSoft.png")));
		lblNewLabel.setHorizontalAlignment(SwingConstants.CENTER);
		contentPane.add(lblNewLabel, "8, 1, 3, 11");
		contentPane.add(btnMedicos, "2, 7, fill, top");
		contentPane.add(btnPacientes, "4, 7, fill, top");
		contentPane.add(btnEspecialidades, "2, 8, fill, fill");
		contentPane.add(btnObrasSociales, "4, 8, fill, center");
		
		contentPane.add(btnSalir, "10, 12, left, bottom");
		this.setVisible(true);
		this.setLocationRelativeTo(null);
		this.pack();
	}

	private void agregarListeners(){
		btnVerAgenda.addActionListener(controlador);
		btnMedicos.addActionListener(controlador);
		btnPacientes.addActionListener(controlador);
		btnObrasSociales.addActionListener(controlador);
		btnEspecialidades.addActionListener(controlador);
		btnSalir.addActionListener(controlador);
	}
	
	//getters y setters
	public JButton getBtnMedicos() {
		return btnMedicos;
	}

	public JButton getBtnPacientes() {
		return btnPacientes;
	}

	public JButton getBtnVerAgenda() {
		return btnVerAgenda;
	}

	public JButton getBtnEspecialidades() {
		return btnEspecialidades;
	}

	public JButton getBtnObrasSociales() {
		return btnObrasSociales;
	}

	public JButton getBtnSalir() {
		return btnSalir;
	}
	
}
